package org.jeecgframework.web.material.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.web.material.entity.ScheduleEntity;
import org.jeecgframework.web.material.service.ScheduleServiceI;
import org.jeecgframework.web.system.pojo.base.TSUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("scheduleService")
@Transactional
public class ScheduleServiceImpl extends CommonServiceImpl implements ScheduleServiceI {

	@Override
	public Map mywork() {
		TSUser user = ResourceUtil.getSessionUserName();
		String hql = "select obj from ScheduleEntity obj where (obj.finishState != '1' or obj.finishState is null) and companyId.id='"+user.getCompany().getId()+"' ";
		List<ScheduleEntity> list = this.findHql(hql);
		List<ScheduleEntity> list_my = new ArrayList<ScheduleEntity>();
		for(ScheduleEntity obj:list){
			if(obj.getFzrids().contains(user.getId())){
				list_my.add(obj);
			}
		}
		Map map = new HashMap();
		map.put("total", list_my.size());
		map.put("results", list_my);
		return map;
	}

}